package com.Lixiaoqian.CardPlay.common.customview;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.Lixiaoqian.CardPlay.R;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by HuangZhiBo on 2017/3/29/029.
 */

public class TopToolBar extends Toolbar {

    private TextView textCenter;
    private ImageView ImageRight;

    public TopToolBar(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    private void initView(Context context) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.toolbar_layout, this);
        textCenter = (TextView) inflate.findViewById(R.id.tv_topbar_center);
        ImageRight = (ImageView) inflate.findViewById(R.id.iv_topbar_right);
        AutoUtils.auto(inflate);
    }


    public void setTextLeft(String title) {
        if (title == null) {
            this.setTitle("");
        } else
            this.setTitle(title);
    }

    public ImageView getIvRight() {
        ImageRight.setVisibility(VISIBLE);
        return  ImageRight;
    }

    public void setTextCenter(String info){
        textCenter.setVisibility(VISIBLE);
        textCenter.setText(info);
    }
}
